import qs from 'qs'
import {AxiosRequestConfig, AxiosResponse} from 'axios'

const axiosConfig: AxiosRequestConfig = {
   baseURL: 'https://test.ivorycapitalasia.cn',
   //请求后的数据处理
   transformResponse: [
      function (data: AxiosResponse) {
         return data
      }
   ],
   //查询对象序列化函数
   paramsSerializer: function (params: any) {
      return qs.stringify(params)
   },
   //超时设置s
   timeout: 3000,
   //跨域是否带token,
   //ithCredentials: true,
   responseType: 'json',
   //xsrf设置
   xsrfCookieName: 'XSRF-TOKEN',
   xsrfHeaderName: 'X-XSRF-TOKEN',
   //最多转发数，用于node.js
   maxRedirects: 5,
   //最大响应数据大小
   maxContentLength: 2000,
   //自定义错误状态码范围
   validateStatus: function (status: number) {
      return status >= 200 && status < 300
   }
}

export default axiosConfig
